package com.xjj.api;

import java.io.Serializable;

public class ResponseDTO implements Serializable {
    private static final long serialVersionUID = 310854062175746208L;
    private Object code;
    private String msg;
    private Object data;

    public ResponseDTO (){
    }

    public ResponseDTO(Object code, String msg, Object data) {
        super();
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResponseDTO success(Object data) {
        return new ResponseDTO("success", "success", data);
    }

    public static ResponseDTO fail(Object code, String msg) {
        return new ResponseDTO(code, msg, null);
    }

    public static ResponseDTO fail(Object code, String msg, Object data) {
        return new ResponseDTO(code, msg, data);
    }

    public boolean success() {
        return "success".equals(code);
    }

    public Object getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResponseDTO{" +
                ", code='" + code + '\'' +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
